package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.OrrMaterialSummaryService;
import com.yunhai.model.entity.orr.OrrMaterialSummaryEntity;
import com.yunhai.model.vo.orr.OrrMaterialSummaryQuery;
import com.yunhai.model.vo.orr.OrrMaterialSummaryVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/orrMaterialSummary")
public class OrrMaterialSummaryController {

	@Resource
	private OrrMaterialSummaryService orrMaterialSummaryService;


	/**
	 * 获取 OrrMaterialSummary 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getOrrMaterialSummaryPagination(PaginationVo paginationVo, OrrMaterialSummaryQuery orrMaterialSummaryQuery ) throws Exception {
		IPage page = orrMaterialSummaryService.getOrrMaterialSummaryPagination(paginationVo, orrMaterialSummaryQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 OrrMaterialSummary 所有数据
	 */
	@GetMapping("/allList")
	public Ret getOrrMaterialSummaryAllList( OrrMaterialSummaryQuery orrMaterialSummaryQuery ) throws Exception {
		List<OrrMaterialSummaryEntity> list = orrMaterialSummaryService.getOrrMaterialSummaryAllList( orrMaterialSummaryQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 OrrMaterialSummary 详情
	 */
	@GetMapping("/{id}")
	public Ret getOrrMaterialSummaryDetailById(@PathVariable Long id) throws Exception {

	    OrrMaterialSummaryEntity orrMaterialSummaryEntity = orrMaterialSummaryService.getOrrMaterialSummaryDetail(id);
		return Ret.ok(orrMaterialSummaryEntity);
	}


	/**
	 * 新增 OrrMaterialSummary
	 * */
	@PostMapping("")
	public Ret addOrrMaterialSummary(@RequestBody OrrMaterialSummaryVo orrMaterialSummaryVo) throws Exception {

		orrMaterialSummaryService.addOrrMaterialSummary(orrMaterialSummaryVo);
		return Ret.ok();
	}


	/**
	 * 更新 OrrMaterialSummary
	 * */
	@PutMapping("")
	public Ret updateOrrMaterialSummary(@RequestBody OrrMaterialSummaryVo orrMaterialSummaryVo) throws Exception {

		orrMaterialSummaryService.updateOrrMaterialSummary(orrMaterialSummaryVo);
		return Ret.ok();
	}


	/**
	 * 删除 OrrMaterialSummary
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveOrrMaterialSummary( @RequestBody List<Long> ids ) throws Exception {

	    orrMaterialSummaryService.batchRemoveOrrMaterialSummary(ids);
		return Ret.ok();
	}
}
